%This script creates an example with two cluster with a bit of overlapping
%on each dimension

d = 6;
center = 5;
cluster_size = 10*d;

overlaps = [2, 5, 7, 10] ; %overlapping
for i=1:length(overlaps)
    overlap = overlaps(i);
    r = sqrt(d*center^2) - overlap; 
    C1 = create_cluster(center*ones(1,d)', r*ones(1,d)', cluster_size);
    C2 = create_cluster(-center*ones(1,d)', r*ones(1,d)', cluster_size);
    
    %real classification
    real_class = [ones(1,cluster_size), 2*ones(1,cluster_size)];

    C = [C1, C2];

    %K-means
    c = kmeans(C',2,'replicates',5);
    figure;
    [sil, h] = silhouette(C',c);
    randindex = RandIndex(real_class, c);
    t = sprintf('Using overlapping = %d, radius = %f\nrand index = %f', ...
        overlap, r, randindex);
    title(t);
end


%Conclusions - the less overlap, the more distinct - 
%better results
